<template>
  <div class="demo5">
    {{chooseIndex}}
    <div v-for="(item,index) in issucessList" @click="select(index)">
      {{item.title}}
    </div>
    <div v-html="bodyString"></div>
  </div>

</template>

<script>
  import axios from 'axios'

  var url = 'https://api.github.com/repos/eyasliu/blog/issues'
  export default {
    name: 'demo5',
    components: {},
    props: {},
    data() {
      return {
        issucessList: [],
        chooseIndex: 0,
        bodyString: ''
      };
    },
    mounted() {
      axios.get(url).then(res => {
        console.log(res)
        this.issucessList = res.data;
        this.setBody();

      })

    },
    methods: {
      select(index) {
        this.chooseIndex = index
        this.setBody();
      },
      setBody() {
        axios.post('https://api.github.com/markdown', {
          "text": this.issucessList[this.chooseIndex].body,
          "mode": "gfm",
          "context": "github/gollum"
        }).then(res => {
          this.bodyString = res.data;
        })

      }

    },
    computed: {}
  };
</script>

<style scoped lang="less">
  .demo5 {
  }
</style>
<style lang="less">
  .demo5 {
  }
</style>
